<!DOCTYPE html>
<html lang="en" xmlns:th="http://www.thymeleaf.org">
<head>
    <base href="/">
<!--在此页面定义根路径-->


    <meta charset="UTF-8">
    <title>Title</title>
    <link rel="stylesheet" href="layui/css/layui.css">
<!--http://layui.apixx.net/doc/index.html-->

    <style>
        #imgbox img{
            width: 100px;
            height: 100px;

        }
    </style>
</head>
<body>

<button type="button" id="uploadBTN" class="layui-btn">上传</button>
<div id="imgbox"></div>
<script src="layui/layui.all.js"></script>
<script>
    const upload=layui.upload;
    const $=layui.$;
    // const form=layui.form;

    upload.render({
        elem:"#uploadBTN",
    //     指定一个选择器
        url:'file/upload',
    //     上传到哪
        done: function(res){
            console.log(res);
            let src=res.data[0].src;
            $('#imgbox').append("<img src='" + src + "'/>");
        },
        error: function(){

        }
    });
</script>
</body>
</html>